<?php

namespace app\models\Child;

use Yii;

/**
 * This is the model class for table "t_user_nersing_rel".
 *
 * @property integer $rel_id
 * @property integer $booking_id
 * @property integer $user_id
 * @property integer $patient_id
 * @property integer $doctor_id
 * @property integer $type_id
 * @property integer $nursing_id
 * @property string $nursing_name
 * @property string $create_time
 */
class TUserNersingRel extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 't_user_nersing_rel';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['rel_id','push_id','booking_id', 'user_id', 'patient_id', 'doctor_id', 'type_id', 'nursing_id','nursing_value'], 'integer'],
            [['nursing_name','type_name'], 'string'],
            [['create_time'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'push_id' =>'Push ID',
            'rel_id' => 'Rel ID',
            'booking_id' => 'Booking ID',
            'user_id' => 'User ID',
            'patient_id' => 'Patient ID',
            'doctor_id' => 'Doctor ID',
            'type_id' => 'Type ID',
	    'type_name' => 'Type Name',
            'nursing_id' => 'Nursing ID',
            'nursing_name' => 'Nursing Name',
            'nursing_value' => 'Nursing Value',
            'create_time' => 'Create Time',
        ];
    }
    
    /*
     * 批量插入数据
     */
    public function setAnswer($answer)
    {
	$this->push_id = $answer['rel_id'];
        $this->booking_id = $answer['booking_id'];
        $this->user_id = $answer['user_id'];
        $this->patient_id = $answer['patient_id'];
        $this->doctor_id = $answer['doctor_id'];
        $this->type_id = $answer['type_id'];
	$this->type_name = $answer['type_name'];
        $this->nursing_id = $answer['nursing_id'];
        $this->nursing_name = $answer['nursing_name'];
        $this->nursing_value = $answer['nursing_value'];
        $this->create_time = $answer['create_time'];
        
        return $this->save();
        
    }
    
    /*
     * 判断是否答题
     */
    public function check($rel_id)
    {
        $list = $this->find()
                ->where(['push_id' => $rel_id])
                ->asArray()
                ->all();
        return $list;
    }
}
